package com.conferenceroom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.conferenceroom.entity.Orders;
import com.conferenceroom.vo.refundOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {
    @Select({
            "<script>",
            "SELECT o.order_id, o.user_id, o.room_id, o.start_time, o.end_time,",
            "       o.create_time, o.cancel_time, o.payment_status, o.total_fee,",
            "       u.username, u.real_name, u.company, u.phone",
            "FROM orders o",
            "JOIN user u ON o.user_id = u.user_id",
            "WHERE o.payment_status = 4",  // 状态为 4（退款待审核）
            "</script>"
    })
    @Results({
            @Result(property = "orderId", column = "order_id"),
            @Result(property = "userId", column = "user_id"),
            @Result(property = "roomId", column = "room_id"),
            @Result(property = "startTime", column = "start_time"),
            @Result(property = "endTime", column = "end_time"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "cancelTime", column = "cancel_time"),
            @Result(property = "paymentStatus", column = "payment_status"),
            @Result(property = "totalFee", column = "total_fee"),
            @Result(property = "username", column = "username"),
            @Result(property = "realName", column = "real_name"),
            @Result(property = "company", column = "company"),
            @Result(property = "phone", column = "phone")
    })
    List<refundOrder> selectRefundOrders();
}
